With the widespread applications of Massive Open Online Courses (MOOCs) platforms, an effective method is needed for personalized course recommendation. In view of the existing course recommendation methods, which usually use the course learning records to establish the overall static representation for users’ learning interests, while ignoring the dynamic changes of learning interests and users’ short-term learning interests, a Hierarchical and Phased Attention Network (HPAN) was proposed to carry out personalized course recommendation. In the first layer of the network, the attention network was used to obtain the user’s long- and short-term learning interests. In the second layer of the network, the user’s long- and short-term learning interests and short-term interaction sequence were combined to obtain the user’s interest vector through the attention network, then the preference value of the user’s interest vector with each course vector was calculated, and courses were recommended for the user according to the result. Experimental results on public dataset XuetangX show that, compared with the second best SHAN (Sequential Hierarchical Attention Network) model, HPAN model has the Recall@5 increased by 12.7%; compared with FPMC (Factorizing Personalized Markov Chains) model, HPAN model has the MRR@20 increased by 15.6%. HPAN model has better recommendation effect than the comparison models, and can be used for practical personalized course recommendation.